//index.js
//获取应用实例
const app = getApp()
const host = require('../../config').host

Page({
  data: {
    motto: 'Hello World',
    userInfo: {},
    selected: "",
    selecteds: "",
    display:"display",
    displays:"",
    functions:"close",
    hasUserInfo: false,
    canIUse: wx.canIUse('button.open-type.getUserInfo')
  },
  //事件处理函数
  bindViewTap: function() {
    wx.navigateTo({
      url: '../logs/logs'
    })
  },
  toScore: function(e){
    wx.navigateTo({
      url: `./adminNewExpert?id=${e.currentTarget.dataset.id}`
    })
  },
  toClick: function(event){
    var selectId = event.currentTarget.dataset.id;
    this.setData({
      selectId:selectId,
    });
    this.expert_detail(selectId);
  },
  toExpert: function(event){
    var currentExpertId = this.data.currentExpertId;
    var functions = event.currentTarget.dataset.function;
    if(functions==="open"){
      this.setData({
        selected:"",
        selecteds:"",
        display:"display",
        displays:"",
        functions:"close",
      });
    }else{
      this.setData({
        selected:"rotateRight",
        selecteds:"selecteds",
        display:"",
        displays:"display",
        functions:"open",
      });
    }
    this.setData({
      
    })
  },
  onLoad: function () {
    this.select()
  },
  fix: function(){
    var selectId = this.data.selectId
    wx.navigateTo({
      url: `./adminNew?selectId=${selectId}`
    })
  },
  expert_detail:function(selectId){
    var that = this
    wx.request({
      url: host+'api/user/expert_detail',
      data:{selectId:selectId},
      success: function(res){
        that.setData({
          expert_detail: res.data,
        })
      },
      fail: function(data){
        // console.log(data)
      }
    })
  },
  select: function(){
    var that = this
    wx.request({
      url: host+'api/user/select',
      data:{expert_id:app.globalData.id},
      success: function(res){
        that.setData({
          select: res.data.group,
          selectId: res.data.id
        })
        that.expert_detail(res.data.id);
      },
      fail: function(data){
        // console.log(data)
      }
    })
  },
  getUserInfo: function(e) {
    console.log(e)
    app.globalData.userInfo = e.detail.userInfo
    this.setData({
      userInfo: e.detail.userInfo,
      hasUserInfo: true
    })
  }
})
